
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[_Procedures]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[_Procedures](
	[idProcedure] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK__Procedures] PRIMARY KEY CLUSTERED 
(
	[idProcedure] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[_Status]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[_Status](
	[idStatus] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK__Status] PRIMARY KEY CLUSTERED 
(
	[idStatus] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AdministrationVias]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[AdministrationVias](
	[idAdministrationVia] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_AdministrationVias] PRIMARY KEY CLUSTERED 
(
	[idAdministrationVia] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Allergies]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Allergies](
	[idAllergie] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_Allergies] PRIMARY KEY CLUSTERED 
(
	[idAllergie] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BloodTypes]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[BloodTypes](
	[idBloodType] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [Char](20) NULL ,
	
 CONSTRAINT [PK_BloodTypes] PRIMARY KEY CLUSTERED 
(
	[idBloodType] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Conditions]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Conditions](
	[idConditions] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_Conditions] PRIMARY KEY CLUSTERED 
(
	[idConditions] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ContactData]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[ContactData](
	[idContactData] [int] IDENTITY(1,1) NOT NULL ,
	[Cel] [Char](18) NULL ,
	[Direction] [VarChar](255) NULL ,
	[FirstName] [Char](15) NOT NULL ,
	[LasName2] [Char](15) NULL ,
	[LastName] [Char](15) NULL ,
	[Mail] [VarChar](100) NULL ,
	[MiddleName] [Char](15) NULL ,
	[Tel] [Char](18) NULL ,
	
 CONSTRAINT [PK_ContactData] PRIMARY KEY CLUSTERED 
(
	[idContactData] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Inmunizations]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Inmunizations](
	[idInmunization] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_Inmunizations] PRIMARY KEY CLUSTERED 
(
	[idInmunization] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Medications]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Medications](
	[idMedication] [int] IDENTITY(1,1) NOT NULL ,
	[AdminVia] [int] NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_Medications] PRIMARY KEY CLUSTERED 
(
	[idMedication] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Patients]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Patients](
	[idPatient] [int] IDENTITY(1,1) NOT NULL ,
	[idUser] [int] NOT NULL ,
	
 CONSTRAINT [PK_Patients] PRIMARY KEY CLUSTERED 
(
	[idPatient] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PersonAllergies]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PersonAllergies](
	[idPersonAllergie] [int] IDENTITY(1,1) NOT NULL ,
	[Allergie] [int] NOT NULL ,
	[EndDate] [datetime] NULL ,
	[Obs] [VarChar](255) NULL ,
	[Person] [int] NOT NULL ,
	[Severity] [int] NOT NULL ,
	[StartDate] [datetime] NULL ,
	[Status] [int] NOT NULL ,
	
 CONSTRAINT [PK_PersonAllergies] PRIMARY KEY CLUSTERED 
(
	[idPersonAllergie] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PersonConditions]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PersonConditions](
	[idPersonCondition] [int] IDENTITY(1,1) NOT NULL ,
	[Condition] [int] NOT NULL ,
	[EndDate] [datetime] NULL ,
	[Obs] [VarChar](255) NULL ,
	[Person] [int] NOT NULL ,
	[StartDate] [datetime] NULL ,
	[Status] [int] NOT NULL ,
	
 CONSTRAINT [PK_PersonConditions] PRIMARY KEY CLUSTERED 
(
	[idPersonCondition] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PersonInmunizations]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PersonInmunizations](
	[PersonInmunization] [int] IDENTITY(1,1) NOT NULL ,
	[Date] [datetime] NULL ,
	[idInmunization] [int] NOT NULL ,
	[Person] [int] NOT NULL ,
	
 CONSTRAINT [PK_PersonInmunizations] PRIMARY KEY CLUSTERED 
(
	[PersonInmunization] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PersonMetrics]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PersonMetrics](
	[idPersonMetric] [int] IDENTITY(1,1) NOT NULL ,
	
 CONSTRAINT [PK_PersonMetrics] PRIMARY KEY CLUSTERED 
(
	[idPersonMetric] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PersonProcedures]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PersonProcedures](
	[idPersonProcedure] [int] IDENTITY(1,1) NOT NULL ,
	[EndDate] [datetime] NULL ,
	[idProcedure] [int] NOT NULL ,
	[Person] [int] NOT NULL ,
	[StartDate] [datetime] NULL ,
	
 CONSTRAINT [PK_PersonProcedures] PRIMARY KEY CLUSTERED 
(
	[idPersonProcedure] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Persons]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Persons](
	[idPerson] [int] IDENTITY(1,1) NOT NULL ,
	[BloodType] [int] NOT NULL ,
	[DateOfBirth] [datetime] NULL ,
	[idContactData] [int] NOT NULL ,
	[idPatient] [int] NOT NULL ,
	[Race] [int] NOT NULL ,
	[Sex] [int] NOT NULL ,
	
 CONSTRAINT [PK_Persons] PRIMARY KEY CLUSTERED 
(
	[idPerson] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PersonTestResult]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PersonTestResult](
	[idPersonTestRes] [int] IDENTITY(1,1) NOT NULL ,
	[Date] [datetime] NULL ,
	[Person] [int] NOT NULL ,
	[TestResult] [int] NOT NULL ,
	[Units] [Char](20) NULL ,
	[Value] [Decimal](18,0) NULL ,
	
 CONSTRAINT [PK_PersonTestResult] PRIMARY KEY CLUSTERED 
(
	[idPersonTestRes] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PesonMedications]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[PesonMedications](
	[idPersonMedication] [int] IDENTITY(1,1) NOT NULL ,
	[EndDate] [datetime] NULL ,
	[HowMany] [VarChar](56) NULL ,
	[HowOften] [VarChar](56) NULL ,
	[Medication] [int] NOT NULL ,
	[Obs] [VarChar](255) NULL ,
	[Person] [int] NOT NULL ,
	[StarDate] [datetime] NULL ,
	[Status] [int] NOT NULL ,
	
 CONSTRAINT [PK_PesonMedications] PRIMARY KEY CLUSTERED 
(
	[idPersonMedication] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Races]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Races](
	[idRace] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](50) NULL ,
	
 CONSTRAINT [PK_Races] PRIMARY KEY CLUSTERED 
(
	[idRace] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Severitys]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Severitys](
	[idSeverity] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_Severitys] PRIMARY KEY CLUSTERED 
(
	[idSeverity] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Sexs]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Sexs](
	[idSex] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [Char](20) NULL ,
	
 CONSTRAINT [PK_Sexs] PRIMARY KEY CLUSTERED 
(
	[idSex] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestResults]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[TestResults](
	[idTestResult] [int] IDENTITY(1,1) NOT NULL ,
	[Name] [VarChar](255) NULL ,
	
 CONSTRAINT [PK_TestResults] PRIMARY KEY CLUSTERED 
(
	[idTestResult] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U'))
BEGIN

CREATE TABLE [dbo].[Users](
	[idUser] [int] IDENTITY(1,1) NOT NULL ,
	[Login] [Char](15) NULL ,
	[UserPassword] [Char](15) NULL ,
	
 CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
	[idUser] ASC 
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

END

GO



IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonPro__idPro__2704CA5F]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonProcedures]'))
ALTER TABLE [dbo].[PersonProcedures]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonPro__idPro__2704CA5F]
FOREIGN KEY([idProcedure])
REFERENCES [dbo].[_Procedures] ([idProcedure])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonAll__Statu__3DE82FB7]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonAllergies]'))
ALTER TABLE [dbo].[PersonAllergies]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonAll__Statu__3DE82FB7]
FOREIGN KEY([Status])
REFERENCES [dbo].[_Status] ([idStatus])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonCon__Statu__336AA144]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonConditions]'))
ALTER TABLE [dbo].[PersonConditions]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonCon__Statu__336AA144]
FOREIGN KEY([Status])
REFERENCES [dbo].[_Status] ([idStatus])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PesonMedi__Statu__382F5661]') AND parent_object_id = OBJECT_ID(N'[dbo].[PesonMedications]'))
ALTER TABLE [dbo].[PesonMedications]  WITH NOCHECK ADD  CONSTRAINT [FK__PesonMedi__Statu__382F5661]
FOREIGN KEY([Status])
REFERENCES [dbo].[_Status] ([idStatus])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Medicatio__Admin__19AACF41]') AND parent_object_id = OBJECT_ID(N'[dbo].[Medications]'))
ALTER TABLE [dbo].[Medications]  WITH NOCHECK ADD  CONSTRAINT [FK__Medicatio__Admin__19AACF41]
FOREIGN KEY([AdminVia])
REFERENCES [dbo].[AdministrationVias] ([idAdministrationVia])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonAll__Aller__3BFFE745]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonAllergies]'))
ALTER TABLE [dbo].[PersonAllergies]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonAll__Aller__3BFFE745]
FOREIGN KEY([Allergie])
REFERENCES [dbo].[Allergies] ([idAllergie])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Persons__BloodTy__214BF109]') AND parent_object_id = OBJECT_ID(N'[dbo].[Persons]'))
ALTER TABLE [dbo].[Persons]  WITH NOCHECK ADD  CONSTRAINT [FK__Persons__BloodTy__214BF109]
FOREIGN KEY([BloodType])
REFERENCES [dbo].[BloodTypes] ([idBloodType])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonCon__Condi__318258D2]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonConditions]'))
ALTER TABLE [dbo].[PersonConditions]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonCon__Condi__318258D2]
FOREIGN KEY([Condition])
REFERENCES [dbo].[Conditions] ([idConditions])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Persons__idConta__2334397B]') AND parent_object_id = OBJECT_ID(N'[dbo].[Persons]'))
ALTER TABLE [dbo].[Persons]  WITH NOCHECK ADD  CONSTRAINT [FK__Persons__idConta__2334397B]
FOREIGN KEY([idContactData])
REFERENCES [dbo].[ContactData] ([idContactData])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonInm__idInm__2DB1C7EE]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonInmunizations]'))
ALTER TABLE [dbo].[PersonInmunizations]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonInm__idInm__2DB1C7EE]
FOREIGN KEY([idInmunization])
REFERENCES [dbo].[Inmunizations] ([idInmunization])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PesonMedi__Medic__36470DEF]') AND parent_object_id = OBJECT_ID(N'[dbo].[PesonMedications]'))
ALTER TABLE [dbo].[PesonMedications]  WITH NOCHECK ADD  CONSTRAINT [FK__PesonMedi__Medic__36470DEF]
FOREIGN KEY([Medication])
REFERENCES [dbo].[Medications] ([idMedication])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Persons__idPatie__22401542]') AND parent_object_id = OBJECT_ID(N'[dbo].[Persons]'))
ALTER TABLE [dbo].[Persons]  WITH NOCHECK ADD  CONSTRAINT [FK__Persons__idPatie__22401542]
FOREIGN KEY([idPatient])
REFERENCES [dbo].[Patients] ([idPatient])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonAll__Perso__3B0BC30C]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonAllergies]'))
ALTER TABLE [dbo].[PersonAllergies]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonAll__Perso__3B0BC30C]
FOREIGN KEY([Person])
REFERENCES [dbo].[Persons] ([idPerson])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonCon__Perso__32767D0B]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonConditions]'))
ALTER TABLE [dbo].[PersonConditions]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonCon__Perso__32767D0B]
FOREIGN KEY([Person])
REFERENCES [dbo].[Persons] ([idPerson])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonInm__Perso__2EA5EC27]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonInmunizations]'))
ALTER TABLE [dbo].[PersonInmunizations]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonInm__Perso__2EA5EC27]
FOREIGN KEY([Person])
REFERENCES [dbo].[Persons] ([idPerson])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonPro__Perso__2610A626]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonProcedures]'))
ALTER TABLE [dbo].[PersonProcedures]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonPro__Perso__2610A626]
FOREIGN KEY([Person])
REFERENCES [dbo].[Persons] ([idPerson])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonTes__Perso__2AD55B43]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonTestResult]'))
ALTER TABLE [dbo].[PersonTestResult]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonTes__Perso__2AD55B43]
FOREIGN KEY([Person])
REFERENCES [dbo].[Persons] ([idPerson])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PesonMedi__Perso__373B3228]') AND parent_object_id = OBJECT_ID(N'[dbo].[PesonMedications]'))
ALTER TABLE [dbo].[PesonMedications]  WITH NOCHECK ADD  CONSTRAINT [FK__PesonMedi__Perso__373B3228]
FOREIGN KEY([Person])
REFERENCES [dbo].[Persons] ([idPerson])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Persons__Races__2057CCD0]') AND parent_object_id = OBJECT_ID(N'[dbo].[Persons]'))
ALTER TABLE [dbo].[Persons]  WITH NOCHECK ADD  CONSTRAINT [FK__Persons__Races__2057CCD0]
FOREIGN KEY([Race])
REFERENCES [dbo].[Races] ([idRace])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonAll__Sever__3CF40B7E]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonAllergies]'))
ALTER TABLE [dbo].[PersonAllergies]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonAll__Sever__3CF40B7E]
FOREIGN KEY([Severity])
REFERENCES [dbo].[Severitys] ([idSeverity])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Persons__Sex__1F63A897]') AND parent_object_id = OBJECT_ID(N'[dbo].[Persons]'))
ALTER TABLE [dbo].[Persons]  WITH NOCHECK ADD  CONSTRAINT [FK__Persons__Sex__1F63A897]
FOREIGN KEY([Sex])
REFERENCES [dbo].[Sexs] ([idSex])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__PersonTes__TestR__29E1370A]') AND parent_object_id = OBJECT_ID(N'[dbo].[PersonTestResult]'))
ALTER TABLE [dbo].[PersonTestResult]  WITH NOCHECK ADD  CONSTRAINT [FK__PersonTes__TestR__29E1370A]
FOREIGN KEY([TestResult])
REFERENCES [dbo].[TestResults] ([idTestResult])

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__Patients__idUser__1C873BEC]') AND parent_object_id = OBJECT_ID(N'[dbo].[Patients]'))
ALTER TABLE [dbo].[Patients]  WITH NOCHECK ADD  CONSTRAINT [FK__Patients__idUser__1C873BEC]
FOREIGN KEY([idUser])
REFERENCES [dbo].[Users] ([idUser])

